import { createApp } from 'vue'

import { router } from '@/routers'
import { setupStore } from '@/store/setup'
import { setupDirective } from '@/directive'
import { setupRouterGuard } from './routers'
import { useInsRely } from '@bitwit/base-com-render'

import App from './App.vue'

import { updatwENV } from '@/utils/env'
import { setupAnt, setupVxe, setupIcon, setupVant } from '@/tools'

async function bootstrap() {
  const app = createApp(App) // 生成实例

  updatwENV()

  useInsRely(app)
  setupStore(app) // 全局注册 状态管理(store)
  setupDirective(app) // 全局注册 自定义指令(directive)
  setupRouterGuard(router) // 注册路由守卫

  setupAnt(app) // 挂载ant
  setupVxe(app) // 挂载vxe表格
  setupIcon(app) // 挂载图标组件
  setupVant(app) // 挂载 Vant

  app.use(router) // 挂载路由
  app.mount('#app') // 实例化容器
}

bootstrap()
